/**
 * Copyright (c) 2011 eelpo.com
 * All rights reserved.
 */
package com.eelpo.common.query;

import com.eelpo.common.util.BlankUtils;

/**
 * <pre>
 * 
 * like和ilike的匹配模式，总共分四种匹配模式
 * 
 * EXACT：严格匹配
 * ANYWHERE：两端匹配
 * START：开始端匹配
 * END：末端匹配
 * 
 * </pre>
 * 
 * @author <a href="mailto:Brian@eelpo.com">汪洪州</a>
 * @since 1.0
 */
public enum MatchMode {
	EXACT, ANYWHERE, START, END;

	public Object getParameter(Object parameter) {
		if (BlankUtils.isBlank(parameter))
			return null;

		switch (this) {
		case START:
			return "%" + parameter;
		case END:
			return parameter + "%";
		case ANYWHERE:
			return "%" + parameter + "%";
		default:
			return parameter;
		}
	}
}
